<?php

namespace App\Http\Controllers;

use App\Framework\Session\ManagerSession;
use Gregwar\Captcha\CaptchaBuilder;
use Illuminate\Http\Request;

class CommonController extends Controller
{
    //权限不足提示页
    public function noPower()
    {
        return view('shared.noPower');
    }

    /**
     * 获取后台验证码
     * @param Request $request
     */
    public function getCaptcha(Request $request){
        //创建验证码对象
        $builder= new CaptchaBuilder();
        //生成验证码
        $builder->build();
        //获取验证码字符串
        $phrase = $builder->getPhrase();
        //将验证码写入会话
        ManagerSession::setCaptcha($phrase);
        //设置http返回头
        header('Content-type: image/jpeg');
        //返回验证码图片
        $builder->output();
    }
}
